package com.gitee.wsl.ext.string

import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid


@OptIn(ExperimentalUuidApi::class)
fun String.isUUID(): Boolean {
    toUUIDOrNull()?:return false
    return true
}

@OptIn(ExperimentalUuidApi::class)
fun String.toUUID(): Uuid {
    return Uuid.parse(this)
}

 @OptIn(ExperimentalUuidApi::class)
 fun String.toUUIDOrNull(): Uuid? {
    return try {
        this.toUUID()
    } catch (e: IllegalArgumentException) {
        null
    }
}